package com.xyh.jdk8Demo;


import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @version v1.0
 * @类描述：  ::
 * @项目名称：
 * @包名： com.xyh.jdk8Demo
 * @类名称：Sudent
 * @创建人：YIHANG.XU
 * @创建时间：2020/9/153:50 下午
 * @修改人：YIHANG.XU
 * @修改时间：2020/9/153:50 下午
 * @修改备注：
 * @Copyright
 */
public class Student {
    private String name = "开始";
    private double score;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getNames() {
        return "1";
    }

    public String setGetName(String names) {
        this.name = names;
        return "开始测试解决：" + name;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public boolean getBoolean(String chunxiao){
        if(chunxiao.equals("chunxiao")){
            return true;
        }
        return false;
    }
    public static void main(String[] args) {
        Student sudent = new Student();
        //设置一个参数无返回
        Consumer<String> setName = sudent::setName;
        setName.accept("ss");

        //无参返回结果
        Supplier<String> getName = sudent::getName;
        System.out.println(getName.get());

        //静态方法
        Supplier<String> s = Student::getNames;
        System.out.println(s.get());

        //设置参数有返回值
        Function<String, String> setGetName = sudent::setGetName;
        String aa = setGetName.apply("aa");
        System.out.println(aa);

        //设置一个参数返回boolean 表达式
        Predicate<String> getBoolean = sudent::getBoolean;
        boolean aaa = getBoolean.test("chunxiao");
        System.out.println(aaa);

        //返回参数
        Function<String,String> appenFuntion = sudent::setGetName;
        String kais = appenFuntion.apply("kais");
        System.out.println(kais);

        Supplier<String> runnable = () -> sudent.getName();
        String o = runnable.get();
        System.out.println(o);



    }


}
